<include file="Flow:header"/>
<body class="bg-grey">
<div class="wraper">
    <div class="head clearfix">
        <a href="{BEESCRM::U('/base/flow/index',array('conf_id'=>$conf_id))}"
           class="iconfont icon-zuojiantou pull-left"></a>
        <span class="head-name pull-left">我的订单</span>
    </div>

    <empty name="orderList">
        <img style="width: 45%;margin: 25% auto 0" src="/assets/base/flow/images/nodata.png"/>
        <else />
	<!--<div class="lists clearfix">-->
	   <volist name="orderList" id="vo">
           <div class="list-box" id="isPendingPay">
			<div class="lists clearfix">
				<span class="text-red">{BEESCRM:$orderStatus[$vo['status']]}</span>
				<span class="pull-right">{BEESCRM:$vo['create_time']|date="Y-m-d H:i",###}</span>
			</div>
			<div class="lists">
				<p>真实姓名：{BEESCRM:$vo['user_name']}</p>
				<p>手机号码：{BEESCRM:$vo['user_mobile']}</p>
				<p>{BEESCRM:$vo['show_title_identity']}{BEESCRM:$vo['identity']}</p>
			</div>
           
			<div class="lists clearfix">
			<if condition="$vo['status'] eq 0">
				<a href="#" class="btn" id="continuePay">继续付款</a>
				<a href="#" class="btn" id="cancelApplied">取消申请</a><input type="hidden" value="{BEESCRM:$vo['order_id']}">
                <a href="{BEESCRM::U('base/flow/modifyUserInfo',array('conf_id'=>$conf_id,'order_id'=>$vo['order_id']))}" class="btn">修改信息</a>
			<elseif condition="$vo['status'] eq 1" />
				您已付款成功，我们会在1-3个工作日内为您处理，请耐心等待！
			<elseif condition="$vo['status'] eq 2" />
				非常抱歉，您的话费预充值申请审核不通过，不通过原因如下：【{BEESCRM:$vo['nopass_desc']}】我们会尽快给您处理退款！
			<elseif condition="$vo['status'] eq 3" />
				您的话费预充值业务已办理成功，我们会分月为您返还话费，感谢您的理解与支持！
			<elseif condition="$vo['status'] eq 4" />
                退款已成功，请实时关注到账信息！
			<elseif condition="$vo['status'] eq 5" />
				订单已关闭！
			</if>
			</div>
           </div>
	   </volist>
    <!--</div>-->

    </empty>
</div>
<div class="pop-box" id="pass">
    <div class="main">
        <p class="iconfont icon-shenheshibai"></p>
        <div class="main-text">
            <p class="stress text-center">您确定要取消申请吗？</p>
            <div class="btn-box clearfix">
                <a href="#" class="text-btn" id="isPassCancel">取消</a>
                <a href="#" class="text-btn" id="isPassConfirm" >确定</a>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="isStatus" value="{BEESCRM:$orderInfo['status']}">
<input type="hidden" id="conf_id" value="{BEESCRM:$conf_id}">
<input type="hidden" id="openid" value="{BEESCRM:$openid}">
<script src="/assets/base/flow/js/jquery-2.1.0.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="/assets/bower_components/sweetalert/lib/sweet-alert.min.js"></script>
<script src="/assets/base/flow/js/jq.utils.js"></script>
<script>
    var conf_id = "conf_id/" + $("#conf_id").val();
    var order_id ='';
    $("a[id=cancelApplied]").on('click', function () {
        $("#pass").show();
        return  order_id = $(this).next("input").val();
    });
    $("#isPassCancel").on('click', function () {
        $("#pass").hide();
    });
    $("#isPassConfirm").on('click', function () {
        $.ajax({
            url: "/base/flow/modifyOrder/" + conf_id,
            type: "post",
            dataType: 'json',
            async: true,
            data: {order_id:order_id},
            success: function (data) {
                //不用写了
            }
        });
        $("#pass").hide();
        reload();
    });

    $("#continuePay").on('click', function () {
        var confId = $("#conf_id").val();
        var openid = $("#openid").val();
        $.ajax({
            url: "/index.php?g=base&m=flow&a=payAgain&conf_id=" + confId,
            type: "post",
            dataType: 'json',
            async: false,
            data: {confirm: 1,openid:openid},
            success: function (data) {
                if (data.status == 'S') {
                    var wxpay = $.parseJSON(data.wxpay);
                    pay(wxpay);
                } else {
                    $.alert('error', data.message);
                    return false;
                }
            }
        });
    });

    //微支付
    function pay(wxpay) {
        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        } else {
            WeixinJSBridge.invoke(
                    'getBrandWCPayRequest',
                    wxpay,
                    function (res) {
                        WeixinJSBridge.log(res.err_msg);
                        if (res.err_msg == "get_brand_wcpay_request:ok") {
                            paySuccess();
                        } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
                            $.alert('error', '付款已取消');
                            return false;
                        } else {
                            $.alert('error', '调用微支付失败');
                            return false;
                        }
                    }
            );
        }
    }

    function paySuccess() {
	    reload();
    }

    //页面刷新
    function reload() {
        setTimeout('location.reload()', 1000);
    }
</script>
</body>
</html>